package com.yijdn.common.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 从上下文中获取HttpServletRequest
 * @author zww
 * @date 2018-03-26 09:40
 * <p>
 * Email 971762302@qq.com
 * <p>
 * Describe:
 */
public class HttpContextUtils {

    /**
     * 获取HttpServletRequest对象
     * @return
     */
    public static HttpServletRequest getRequest(){
        return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
    }
}
